package com.kasax.plugin.shadow.utils

import org.gradle.api.Project

class LogUtils {
    private static Project project

    public static void init(Project proj) {
        project = proj
    }

    public static void d(String tag, String msg) {
        if (project != null) {
            project.logger.lifecycle("$tag -> $msg")
        } else {
            println("$tag -> $msg")
        }
    }

    public static void e(String tag, Exception e) {
        if (project != null) {
            project.logger.error("$tag -> error: ${e.message}", e)
        } else {
            println("$tag -> error: ${e.message}")
        }
    }

    public static void e(String tag, String e) {
        if (project != null) {
            project.logger.error("$tag -> error: $e")
        } else {
            println("$tag -> error: $e")
        }
    }

    public static void e(String tag, String msg, Exception e) {
        if (project != null) {
            project.logger.error("$tag -> $msg error: ${e.message}", e)
        } else {
            println("$tag -> $msg error: ${e.message}")
        }
    }
}